<?php
/**
 * Created by PhpStorm.
 * User: 戎大富
 * Date: 2020/6/9
 * Time: 10:19
 */
namespace app\admin\controller;
use think\Db;
use think\Request;
class Keeper extends Base {
    public function index(){
        if(request()->isAjax ()){
            $keyword = trim(input('keyword'), ' ');
            $where = [];
            if(isset($keyword) && $keyword != ''){
                $where['ua.username'] = ['like', '%' . $keyword . '%'];
            }
            $Nowpage = input('page') ? input('page') : 1;
            $limits = input("limit") ? input("limit") : 10;
            $count = Db::name('excel')->alias('a')
                ->join('up_admin ua','ua.id = a.excel_admin','left')
                ->where($where)
                ->count();// 获取总条数

            $lists = Db::name('excel')->alias('a')
                ->join('up_admin ua','ua.id = a.excel_admin','left')
                ->where($where)
                ->field('a.*,ua.username')
                ->page($Nowpage,$limits)
                ->order('a.excel_time asc')
                ->select();


            return json(['code' => 220, 'msg' => '', 'count' => $count,  'data' => $lists]);
        }
        return $this->fetch();
    }
}